home *** CD-ROM | disk | FTP | other *** search
- ///basic particle shader
- //input should be 4 points that are the same, tex coord will expand them in screen space
- //3rd component of tex coord is size of particle
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //view,projection transform
- float4x4 matViewProj;
-
- //camera position in world space
- float4 cameraPos;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Color : COLOR;
- float3 Tex0 : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float4 Color : COLOR;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //transform pos and copy tex coord and color over
- Out.Pos=mul(matViewProj,In.Pos);
- Out.Tex0.xy=In.Tex0.xy;
- Out.Color=In.Color;
-
- //expand outwards from center point, based on distance and tex coord
- float dist=distance(cameraPos.xyz,In.Pos.xyz);
-
- Out.Pos.xy+=(1.0f/sqrt(dist))*(In.Tex0-0.5f)*In.Tex0.z;
-
- //spit out the results
- return Out;
- }
-